﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace WPFSample.DuplicateUniformGridSample
{
    public class DuplicateUniformGrid : Window
    {
        public DuplicateUniformGrid()
        {
            this.Title = "Duplicate Uniform Grid";

            UniformGridAlmost unigrid = new UniformGridAlmost();
            unigrid.Columns = 5;
            this.Content = unigrid;

            Random rand = new Random();
            for (int index = 0; index < 48; index++)
            {
                Button btn = new Button();
                btn.Name = "Button" + index;
                btn.Content = btn.Name;
                btn.FontSize += rand.Next(10);
                unigrid.Children.Add(btn);
            }

            this.AddHandler(Button.ClickEvent, new RoutedEventHandler(ButtonOnClick));
        }

        void ButtonOnClick(object sender, RoutedEventArgs args)
        {
            Button btn = args.Source as Button;
            MessageBox.Show(btn.Name + " has been clicked", this.Title);
        }
    }
}
